package com.ellen.mac.chatdemo.model;


import com.ellen.mac.chatdemo.myinterface.ChatProfileProvider;
import com.ellen.mac.chatdemo.myinterface.ChatProfilesCallBack;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wli on 15/12/4.
 * 实现自定义用户体系
 */
public class CustomUserProvider implements ChatProfileProvider {

    private static CustomUserProvider customUserProvider;

    public synchronized static CustomUserProvider getInstance() {
        if (null == customUserProvider) {
            customUserProvider = new CustomUserProvider();
        }
        return customUserProvider;
    }

    private CustomUserProvider() {
    }

    private static List<ChatKitUser> partUsers = new ArrayList<>();

    @Override
    public void fetchProfiles(List<String> list, ChatProfilesCallBack callBack) {
        List<ChatKitUser> userList = new ArrayList<>();
        for (String userId : list) {
            for (ChatKitUser user : partUsers) {
                if (user.getUserId().equals(userId)) {
                    userList.add(user);
                    break;
                }
            }
        }
        callBack.done(userList, null);
    }

    public List<ChatKitUser> getAllUsers() {
        return partUsers;
    }
}
